<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏后台管理</title>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script src="__STATIC__/boot/js/dropdown.js"></script>
    <style>
        th{
            text-align: center;
            vertical-align: middle!important;
        }
    </style>
</head>
<body>
{include file="base/header" /}
<br/>
<div>
    <div style="width: 300px; float: left">
        <div style="float: left;width: 100px;" >
            <div class="dropdown">
                <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    付款模式
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
                    <li><a href="#" onclick="index()">一件代发</a></li>
                    <li><a href="#" onclick="postbusiness()">寄售</a></li>
                </ul>
            </div>
        </div>
        <div >
            <button type="button" onclick="account()" class="btn btn-primary">添加商家</button>
        </div>
    </div>
</div>
<div style="float: right; margin-top: 5px;margin-bottom: 5px" class="box-title ">
    <form class="form-inline" action="{:url('index/order/index')}" method="get">
        <input type="text" name="title" value="<?php if(isset($title)) echo $title ?>" class="form-control" id="exampleInputEmail3" >
        <input type="submit" class="btn btn-default" value="搜索"/>
        <input type="button" onclick="res()" value="全部显示" class="btn btn-default"/>
    </form>
</div>

<table class="table table-bordered" style="width: 1300px;margin: 0 auto">
    <tr>
        <th>编号</th>
        <th>昵称</th>
        <th>内部账号</th>
        <th>账号</th>
        <th>联系人</th>
        <th>联系电话</th>
        <th>银行</th>
        <th>支行</th>
        <th>收款账号</th>
        <th>操作</th>
    </tr>
    {foreach $result as $val}
    <tr id="del{$val.id}" style="text-align: center">
        <td>{$val.id}</td>
        <td>{$val.name}</td>
        <td>{$val.account}</td>
        <td>{$val.email}</td>
        <td>{$val.linkman}</td>
        <td>{$val.telephone}</td>
        <td>{$val.bank}</td>
        <td>{$val.branch}</td>
        <td>{$val.paymentaccount}</td>
        <td>
            <button onclick="del({$val.id})" type="button" class="btn btn-danger btn-xs">删除</button>
            <button onclick="goods({$val.id})" type="button" class="btn btn-primary btn-xs" >查看商品</button>
            <button onclick="order({$val.id})" type="button" class="btn btn-info btn-xs" >查看订单</button>
            <button onclick="edit({$val.id})" type="button" class="btn btn-default btn-xs">编辑</button>
        </td>
    </tr>
    {/foreach}
</table>
<div style="margin-left: 30px">{$result->render()}</div>
</body>
<script>
    //编辑商家
    function edit(id){
        layer.open({
            type:2,
            title:'修改商家信息',
            anim:2,
            area: ['700px', '600px'],
            content:"{:url('index/account/edit')}?id="+id
        });
    }
    //删除商家
    function del(id) {
        layer.confirm('你确定要删除吗',{bnt:['确定','取消']},
            function () {
                $.ajax({
                    url:"{:url('index/order/delete')}",
                    type:"post",
                    data:"id="+id,
                    dataType:"json",
                    success:function (data) {
                        if(data.success){
                            layer.alert(data.success);
                            $("#del"+id).remove();
                        }
                        if(data.error){
                            layer.alert(data.error);
                        }
                    }
                });
            }
        );
    }
    
    //查看所有商品
    function goods(id) {
        window.location.href = "{:url('index/order/goods')}?id="+id;
    }

    //显示全部
    function res() {
        window.location.href = "{:url('index/order/index')}";
    }

    //添加管理员
    function account() {
        window.location.href = "{:url('index/account/index')}";
    }



    //查看订单
    function order(bid) {
        window.location.href = "{:url('index/order/order')}?bid="+bid;
    }
    
    //查看后付款商家
    function postbusiness() {
        window.location.href = "{:url('index/postbusiness/index')}";
    }

    //查看先付款商家
    function index() {
        window.location.href = "{:url('index/order/index')}";
    }
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
</script>
</html>